/*
 * @Author: szx
 * @Date: 2022-02-24 13:07:38
 * @LastEditTime: 2022-02-24 13:10:58
 * @Description: 
 * @FilePath: \leetcode\300-399\349\349_2.js
 */
var intersection = function(nums1, nums2) {
    // 根据数组大小交换操作的数组
    if(nums1.length < nums2.length) {
        const _ = nums1;
        nums1 = nums2;
        nums2 = _;
    }
    const nums1Set = new Set(nums1);
    const resSet = new Set();

    for(let i = nums2.length - 1; i >= 0; i--) {
        nums1Set.has(nums2[i]) && resSet.add(nums2[i]);
    }
    return Array.from(resSet);
};